package com.train.system.facade;

import cn.hutool.core.bean.BeanUtil;
import com.train.common.group.QueryGroup;
import com.train.common.resp.CommonResp;
import com.train.common.resp.PageResp;
import com.train.system.dto.seat.TrainSeatPageDTO;
import com.train.system.req.seat.TrainSeatPageReq;
import com.train.system.resp.seat.TrainSeatPageResp;
import com.train.system.service.TrainSeatService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * trainSeat Facade 实现类
 * @author baitiaojun
 * @createDate 2025-02-20 23:20:20
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("train-seat")
public class TrainSeatFacade {

    private final TrainSeatService trainSeatService;

    @PostMapping("page")
    public CommonResp pageList(@RequestBody @Validated(QueryGroup.class) TrainSeatPageReq req) {
        TrainSeatPageDTO trainSeatPageDTO = BeanUtil.copyProperties(req, TrainSeatPageDTO.class);
        PageResp<TrainSeatPageResp> pageResp = trainSeatService.pageList(trainSeatPageDTO);
        return CommonResp.ok(pageResp);
    }

    @DeleteMapping("remove/{id}")
    public CommonResp delete(@PathVariable("id") Long id) {
        trainSeatService.remove(id);
        return CommonResp.ok();
    }
}
